using System.Diagnostics;
using System.Xml.Serialization;
using System.Configuration;
using System;
using System.Net;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;

/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name = "SendMOEJBPortSoapBinding", Namespace = "MOService")]
public class SendMOEJB : System.Web.Services.Protocols.SoapHttpClientProtocol
{
    /// <remarks/>
    public SendMOEJB()
    {
        this.Url = ConfigurationManager.AppSettings["SocBayURL"];
        this.UserName = ConfigurationManager.AppSettings["SocBayUid"];
        this.Password = ConfigurationManager.AppSettings["SocBayPwd"];
    }

    private string _UserName;
    private string _Password;

    public string UserName
    {
        get
        {
            return _UserName;
        }
        set
        {
            _UserName = value;
        }
    }

    public string Password
    {
        get
        {
            return _Password;
        }
        set
        {
            _Password = value;
        }
    }

    public SendMOEJB(string serviceURL)
    {
        this.Url = serviceURL;
    }

    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace = "MOService", ResponseNamespace = "MOService")]
    [return: System.Xml.Serialization.SoapElementAttribute("result")]
    public int SendMO(string request_id, string mobile_no, string service_id, string message, string request_time, string username, string password)
    {
        object[] results = this.Invoke("SendMO", new object[] {
															       request_id,
															       mobile_no,
															       service_id,
															       message,
															       request_time,
                                                                   username,
                                                                   password});
        return ((int)(results[0]));
    }

    /// <remarks/>
    public System.IAsyncResult BeginSendMO(string request_id, string mobile_no, string service_id, string message, string request_time, string username, string password, System.AsyncCallback callback, object asyncState)
    {
        return this.BeginInvoke("SendMO", new object[] {
                                                           request_id,
													       mobile_no,
													       service_id,
													       message,
													       request_time,
                                                           username,
                                                           password}, callback, asyncState);
    }

    /// <remarks/>
    public int EndSendMO(System.IAsyncResult asyncResult)
    {
        object[] results = this.EndInvoke(asyncResult);
        return ((int)(results[0]));
    }

    protected override System.Net.WebRequest GetWebRequest(Uri uri)
    {
        System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)base.GetWebRequest(uri);

        if (this.PreAuthenticate)
        {
            byte[] credBuf = new System.Text.UTF8Encoding().GetBytes(_UserName + ":" + _Password);
            request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(credBuf);
        }
        return request;
    }
}
